This page last changed on Jun 14, 2007 by cholmes.

Unfortunately I don't have time to actually write this tutorial. But I think we should have a tutorial on them as they are super powerful.

Some super quick introductions.

Functions are 'expressions', which means that you can stick them most anywhere on a Filter. So instead of saying:

<Filter>
 <PropertyIsEqualTo>
   <PropertyName>DISPERSION_ANGLE</PropertyName>
  <Literal>1</Literal>
</PropertyIsEqualTo>
</Filter>

you can call a SIN function on the dispersion angle.

<Filter>
 <PropertyIsEqualTo>
  <Function name="SIN">
   <PropertyName>DISPERSION_ANGLE</PropertyName>
  </Function>
  <Literal>1</Literal>
</PropertyIsEqualTo>
</Filter>

And there are functions that take multiple arguments:

<Filter>
 <PropertyIsEqualTo>
  <Function name="MAX">
   <PropertyName>num_lanes</PropertyName>
   <Literal>5</Literal>
  </Function>
  <Literal>1</Literal>
</PropertyIsEqualTo>
</Filter>

That gets the max between the num lanes and 5. The results of functions are expressions themselves, so you can pile them on top of one another in arbitrary depth. The main place expressions are used are Filters. They can be used to further filter out data. You can also use Expressions in many places in SLDs, like to determine the color or width or stroke of a geometry.

We have a ton of power in our filters, as we autogenerate a ton of them. The whole java math library, all of JTS, a bunch of quantile/normalization type of things, and more. These can all be applied to your data by just using a function.

Unfortunately there's no documentation for what the arguments one needs to give to the functions. The WFS capabilities document reports the number of arguments, but not their order or what they should be. Some are easy to figure out, most take looking at source code. That's available at:

http://svn.geotools.org/geotools/trunk/gt/modules/library/main/src/main/java/org/geotools/filter/function/

You can inspect a class and see its number of arguments and what the objects for the args are. Someday we should have a nice table explaining what each function does and what its arguments are. That would be nice... If there are any volunteers don't hesitate to ask on the mailing lists how you can help.

Document generated by Confluence on Jan 16, 2008 23:27